package handle

import (
	"epg-mc/database/table/config"
	"net/http"

	session "github.com/ipfans/echo-session"
	"github.com/labstack/echo"
)

var _data = map[string]interface{}{}

func Index(c echo.Context) error {
	c.Redirect(http.StatusMovedPermanently, "/admin/index")
	return nil
}

func Admin(c echo.Context) error {
	uname, ok := c.Get("uname").(string)
	if ok {
		_data["uname"] = uname
	}
	_data["title"] = config.GetValue(config.SiteTitle)
	return c.Render(http.StatusOK, "common/default.html", _data)
}

func Logout(c echo.Context) error {
	sess := session.Default(c)
	sess.Clear()
	return c.Redirect(http.StatusMovedPermanently, "/")
}

func Proxy(c echo.Context) error {
	source := c.QueryParam("source")
	switch source {
	case "influxdb":
	case "consul":
	default:

	}
	return nil
}
